package com.liu.algorithm03;

import java.util.*;

public class StringSort {
    // 确定字符串是否是另一个的排列
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s1 = scan.next();
        String s2 = scan.next();
        System.out.println(sort(s1).equals(sort(s2)) ? "YSE" : "NO");
        System.out.println("----------------------------------------------");
        boolean flag = order(s1, s2);
        if (flag){
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }
    // 方法1:数组
    public static String sort(String s1){
        char[] chars = s1.toCharArray();
        Arrays.sort(chars);
        return new String(chars);
    }
    // 方法2：集合
    public static boolean order(String str1,String str2){
        List<Character> list1 = new ArrayList<>();
        List<Character> list2 = new ArrayList<>();
        for (char c : str1.toCharArray()) {
            list1.add(c);
        }
        for (char c : str2.toCharArray()) {
            list2.add(c);
        }
        Collections.sort(list1);
        Collections.sort(list2);
        if (list1.equals(list2)){
            return true;
        }
        return false;
    }
}
